package com.active.hackson.database.connection;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class BaseConnectionGenerator implements IConnectionGenerator {
    @Override
    public Connection getConnection( String dbUrl, String username, String password ) {
        try {
            return DriverManager.getConnection( dbUrl, username, password );
        } catch ( SQLException e ) {
            e.printStackTrace();
            return null;
        }
    }

    @Override
    public void close( Connection connection ) {
        try {
            connection.close();
        } catch ( SQLException e ) {
            e.printStackTrace();
        }
    }

    @Override
    public void close( Statement statement ) {
        try {
            statement.close();
        } catch ( SQLException e ) {
            e.printStackTrace();
        }
    }

    @Override
    public void close( ResultSet resultSet ) {
        try {
            resultSet.close();
        } catch ( SQLException e ) {
            e.printStackTrace();
        }
    }
}
